package utils

import (
	"context"

	"github.com/go-redis/redis/v8"
)

var RedisConn *redis.Client

func init() {
	// 通过go向redis写入数据和读取数据
	// 1.连接到redis
	client := redis.NewClient(&redis.Options{
		Addr:     "127.0.0.1:6379",
		Username: "root",
		Password: "root",
		DB:       0,
	})
	if err := client.Ping(context.TODO()); err != nil {
		panic(err)
	}

	RedisConn = client
}
